;;;Place text below a line.  Prompts for text layer by entity pick. (uses GETSTYLE USTR MKLAYR)
;;;
;;;	AUTHOR: HENRY C. FRANCIS
;;;		425 N. ASHE ST.
;;;		SOUTHERN PINES, NC 28387
;;;              
;;;		All rights reserved without prejudice.
;;;	Copyright:	4-7-95
;;;	Edited:		3-6-2006
;;;
(DEFUN C:TXBELO ( / pt1 bkp1b bkp1m bkp1r bkp1l bkp1a bkp2b bkp2m bkp2r bkp2l
bkp2a bkp3b bkp3m bkp3r bkp3l bkp3a)
(if mklayr nil (load"mklayr"))
(c:svlayr)
;(setq dimsc (getvar"dimscale"))
(if dimscl nil (load"dimscl"))
(dimscl)
(if getstyle (getstyle "A")(progn (load "getstyle")(getstyle "A")))
(while
  (setq sel1 (nentsel "\nSelect line"))
  (if(or(eq "LINE" (cdr(assoc 0(entget(car sel1)))))(eq "VERTEX" (cdr(assoc 0(entget(car sel1))))))
  (progn
    (setq txstr (ustr 1 "Enter text" (if txstr txstr "") "T"))
    (setq oldcl clayr
          clayr (cdr(assoc 8(entget(car sel1))))
    );setq
    (while (wcmatch (strcase clayr) "*|*")
      (setq clayr (substr clayr 2))
    )
    (if (clnmstd)
      (progn
        (setq mjrg (substr clayr 1 1)
              llt "-"
              prod (substr clayr 3 4)
              colr "6"
              modf "NOTE"
        );setq
        (c:mklayr)
      );progn
      (progn
        (setq clayr oldcl)
        (if c:slent nil (load "slent"))
        (c:slent)
      );progn
    );if
    (setq endp1 (trans(cdr(assoc 10(entget(car sel1)))) 0 1))
    (if (eq "LINE" (cdr(assoc 0(entget(car sel1)))))
      (setq endp2 (trans(cdr(assoc 11(entget(car sel1)))) 0 1))
      (setq endp2 (trans(cdr(assoc 10(entget(entnext(car sel1))))) 0 1))
    );if
    (setq lang (angle endp1 endp2)
          chkang (+ lang (getvar"viewtwist")))
    (if (and(> chkang 1.868)(< chkang 5.01))
      (setq tang (angtos (+ pi lang) 1 4)
            osang (+(* pi 0.5) lang))
      (setq tang (angtos lang 1 4)
            osang (+(* pi 1.5) lang))
    );if
    (setq templ 125)
    (setq txtht (*(/ templ 1000.00)dimsc))
    (setq
      pt1
        (polar
          (polar
            endp1
            lang
            (distance endp1
                      (cond
                        ((and (eq(type(last sel1))'LIST)
                          (eq(type(car(last sel1)))'REAL))
                          (last sel1))
                        ((and (eq(type(cadr sel1))'LIST)
                          (eq(type(caadr sel1))'REAL))
                          (cadr sel1))
                        (T endp1)
                      )
            )
          );polar
          osang
          (* 1.1 txtht)
        )
    );setq
    (command ".text" "j" "mc" pt1 txtht tang txstr)
  );progn
  (princ "\nNot a Line or a Polyline! ")
  );if
);while
(c:rslayr)
(getstyle "")
);defun
